/*
 * UMLSynch plugin for Eclipse
 * http://umlsynch.googlecode.com
 *
 * Copyright 2008-2010, Evgeny Alexeyev
 * Licensed under the EPL - v1.0
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */

package com.googlecode.umlsynch.EclipseDNDWrapper;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

import org.eclipse.swt.dnd.ByteArrayTransfer;
import org.eclipse.swt.dnd.TransferData;

import com.googlecode.umlsynch.eclipse.rpc.Debug.TEclipseDebug;

/**
 * Class for serializing gadgets to/from a byte array
 */
public class GadgetTransfer extends ByteArrayTransfer {
	private static GadgetTransfer instance = new GadgetTransfer();
	private static final String TYPE_NAME = "application/x-cpp-file-list";
	private static final int TYPEID = registerType(TYPE_NAME);
	private TEclipseDebug debug = new TEclipseDebug("GT:");


	/**
	 * Returns the singleton gadget transfer instance.
	 */
	public static GadgetTransfer getInstance() {
		return instance;
	}
	/**
	 * Avoid explicit instantiation
	 */
	private GadgetTransfer() {
	}
	/*
	 * Method declared on Transfer.
	 */
	protected int[] getTypeIds() {
		return new int[] { TYPEID };
	}
	/*
	 * Method declared on Transfer.
	 */
	protected String[] getTypeNames() {
		return new String[] { TYPE_NAME };
	}
	/*
	 * Method declared on Transfer.
	 */
	protected void javaToNative(Object object, TransferData transferData) {
		byte[] bytes = {'H', 'E', 'J'};
		debug.Error("javaToNative");
		if (bytes != null)
			super.javaToNative(bytes, transferData);
	}
	/*
	 * Method declared on Transfer.
	 */
	protected Object nativeToJava(TransferData transferData) {
		debug.Error("nativeToJava");
		byte[] bytes = (byte[])super.nativeToJava(transferData);
		return bytes;
	}
}